Page({
  generateExcel: function (event) {
    wx.cloud.callFunction({
      name: 'excel',
      data:{
        databasename:"device"
      }
    }).then(res => {
      console.log(res.result.fileID)
      wx.showLoading({
        title: '文档打开中...',
      })
      wx.cloud.downloadFile({
        fileID: res.result.fileID
      }).then(res => {
        // get temp file path
        console.log(res.tempFilePath)
        const filePath = res.tempFilePath
        wx.openDocument({
          filePath: filePath,
          success: res => {
            console.log('打开文档成功')
            wx.hideLoading()
          }
        })
      }).catch(error => {
        // handle error
      })
    })
  }
})